#include <iostream>

using namespace std;

const int N = 1e5 + 10;
int h, ne[N], pre[N];
bool st[N];
int main()
{
	pre[1] = h;
	ne[h] = 1;
	int n;
	cin >> n;
	for(int i = 2; i <= n; i++)
	{
		int k, p;
		cin >> k >> p;
		if(p == 0)
		{
			pre[i] = pre[k];
			ne[i] = k;
			ne[pre[k]] = i;
			pre[k] = i;
		}
		else
		{
			pre[i] = k;
			ne[i] = ne[k];
			pre[ne[k]] = i;
			ne[k] = i;
		}
	}
	int m;
	cin >> m;
	while(m--)
	{
		int x;
		cin >> x;
		if(st[x])
		    continue;
		ne[pre[x]] = ne[x];
		pre[ne[x]] = pre[x];
		st[x] = true;
	}
	for(int i = ne[h]; i; i = ne[i])
	    cout << i << " ";
	return 0;
}
